Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
behaviourSubject returns [object][object] when its subscribed

Im working with a bank API for the payment.what banks want to response is he Ban Pay JavaScript will perform an HTTP redirect in the top frame to the completeUrl. what completeUrl the url i should give the bank api to send their response.in my app.component.ts

          this.http.post("BankEndURL",quote,).subscribe(s=>{
    //here i get quote 
      this.newpay=s;
      
      //here im passing the paymentID to my service in angular to store there,because 
            at the end of the transaction ,if its successful i need it to show the transaction data
            this.dataService.setData(s);
       //here i send a quote to backend to give me a bankurl with payment data
       this.http.post("SecondBakednURL",this.newpay).subscribe(s=>{
     
         this.payaddress= s['reDirectAuthorizationHref'];
         //here i open the url to redirect the user to the payment portal
          window.open(this.payaddress);

here is the service i have created :

public sharedData = new BehaviorSubject<any>(null);

constructor() {}

  getData(){   
  return this.sharedData;
       }

setData(data:any){
this.sharedData.next(data);
}

and here is my receiver component,the one which the bank will hit it once the transaction is successful,im going to show the transction data of the user

        constructor(private dataService:DataService) {}

      ngOnInit(): void {
        this.dataService.getData().pipe(
          filter(data => !!data)
        ).subscribe(data => {
          alert(data)
        });

but data here returns null

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In this case, getSharedData() returns the behavior subject itself, so the sensible thing to do in this case is to subscribe to it in order to receive the data that you are emitting when calling setData.

In the receiver component:

ngOnInit(): void {
  this.dataService.getData().pipe(
    filter(data => !!data)
  ).subscribe(data => {
    alert(data)
  });
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!